<template>
  <div class="session-form__container">
    <!-- 头部logo -->
    <div class="header">
      <img src="~@/assets/logo.png"></img>
    </div>
    <!-- 登录表单 -->
    <a-form
      :form="form"
      :label-col="{ span: 0 }"
      :wrapper-col="{ span: 24 }"
      @submit="handleSubmit">
      <a-form-item >
        <a-input
          placeholder="你的账号/admin"
          size="large"
          v-decorator="['username', { rules: [{ required: true, message: '请输入你的账号!' }] }]">
          <a-icon slot="prefix" type="user" />
          <a-tooltip slot="suffix" title="Extra information">
            <a-icon type="info-circle" style="color: rgba(0,0,0,.45)" />
          </a-tooltip>
        </a-input>
      </a-form-item>
      <a-form-item>
        <a-input-password
          placeholder="你的密码/123456"
          size="large"
          v-decorator="['password', { rules: [{ required: true, message: '请输入你的密码!' }] }]">>
          <a-icon slot="prefix" type="lock" />
        </a-input-password>
      </a-form-item>
      <a-form-item :wrapper-col="{ span: 24}">
        <a-button type="primary" html-type="submit" size="large" block>登录</a-button>
      </a-form-item>
    </a-form>
    <!-- 其他登录 -->
    <div class="other_login"></div>
    <!-- 底部信息 -->
    <div class="footer">
      <a>找回密码</a>
      <span>|</span>
      <a>注册账号</a>
    </div>
  </div>
</template>

<script>
// import { apiLogin } from '@/api/user'
export default {
  data () {
    return {
      form: this.$form.createForm(this, { name: 'login' })
    }
  },
  methods: {
    handleSubmit (e) {
      e.preventDefault()
      this.form.validateFields((err, values) => {
        if (!err) {
          this.toLogin(values)
        }
      })
    },
    toLogin (params) {
      this.$store.dispatch('user/login', params).then(res => {
        this.$router.push({ path: '/home' })
      }).catch(error => {
        this.$message.error('登陆失败：' + error)
      })
    }
  }
}
</script>
<style lang="less">
  .session-form__container {
    height: 100%;
    padding: 64px 75px 48px;
    position: relative;
  }
  .header {
    width:80px;
    height:80px;
    box-shadow:0px 0px 60px 0upx rgba(0,0,0,0.1);
    // border-radius:50%;
    // background-color: #000000;
    margin-top: 10px;
    margin-bottom: 10px;
    margin-left: auto;
    margin-right: auto;
  }
  .header img{
    width:60px;
    height:60px;
    // border-radius:50%;
  }
  /* 其他登录方式 */
  .other_login{
    display: flex;
    flex-direction: row;
    justify-content: center;
    align-items: center;
    margin-top: 10px;
    text-align: center;
  }
  /* 底部 */
  .footer{
    display: flex;
    flex-direction: row;
    justify-content: center;
    align-items: center;
    font-size: 15px;
    margin-top: 10px;
    color: rgba(0,0,0,0.7);
    text-align: center;
    height: 40px;
    line-height: 40px;
  }
  .footer span{
    font-size: 15px;
    margin-left: 15px;
    margin-right: 15px;
  }
</style>
